﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ChoViet.CMS.ViewModels.AdEditCMSViewModel>" %>

<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%=Html.Encode(Model.Ad.Title)%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Quay về", "/Ad/IndexCMS/", "back") %>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Chi tiết tin rao:<font color="red"><%=Model.Ad.ID%></font>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Tên người đăng:
                </td>
                <td>
                    <%= Html.Encode(Model.Ad.NameContact)%>
                </td>
                <td class="key">
                    Email
                </td>
                <td>
                    <%= Html.Encode(Model.Ad.EmailContact)%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Di động
                </td>
                <td>
                    <%= Html.Encode(Model.Ad.MobileContact)%>
                </td>
                <td class="key">
                    SĐT bàn
                </td>
                <td>
                    <%= Html.Encode(Model.Ad.PhoneContact)%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Địa chỉ
                </td>
                <td colspan="3">
                    <%=Html.Encode(Model.Ad.AddressContact)%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Tỉnh thành
                </td>
                <td colspan="3">
                    <%=Html.Encode(Model.Ad.City.Name) %>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Danh mục
                </td>
                <td>
                    <%=Html.Encode(Model.Ad.Category.Name)%>
                </td>
                <td class="key">
                    Nhu cầu
                </td>
                <td>
                    <%=Html.Encode(Model.Ad.Demand.Name)%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ảnh đại diện
                </td>
                <td colspan="3">
                    <img src="<%=string.IsNullOrEmpty(Model.Ad.Image) ? "" : Model.Ad.Image%>" width="60px" height="40px" style="float:left"/>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Tiều đề
                </td>
                <td colspan="3">
                    <%= Html.Encode(Model.Ad.Title)%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Nội dung tin rao
                </td>
                <td colspan="3">
                    <%=Model.Ad.Content%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Giá:
                </td>
                <td colspan="3">
                    <%=string.IsNullOrEmpty( Model.Ad.Cost) ? "liên hệ" : Model.Ad.Cost%>
                    Đơn vị:<%= Model.Ad.CostType!= null ? Model.Ad.CostType.Name : ""%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Danh sách tag
                </td>
                <td colspan="3">
                    Chưa có code
                </td>
            </tr>
            <tr>
                <td class="key">
                    Trạng thái Publish:
                </td>
                <td>
                    <%= Model.Ad.PublishYN%> 
                </td>
                <td class="key">
                    Tin nổi bật HOTYN
                </td>
                <td>
                    <%= Model.Ad.Status%>
                    
                </td>
            </tr>
            <tr>
                <td class="key">
                    MetaKeyword
                </td>
                <td>
                    <%=Model.Ad.Keyword%>
                </td>
                <td class="key">
                    MetaTitle
                </td>
                <td>
                    <%=Model.Ad.MetaTitle%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    MetaDescription
                </td>
                <td colspan="3">
                    <%=Model.Ad.MetaDescription%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Link nguồn
                </td>
                <td colspan="3">
                    <%=Model.Ad.SourceUrl%>
                </td>
            </tr>
            <% if (Model.Galleries != null && Model.Galleries.Count > 0)
                         {%>
                         <tr>
                         
                    <td class="key">
                        Ảnh mô tả:
                    </td>
                    <td>
                          <%    foreach (var item in Model.Galleries)
                                { %>
                             <span id="img<%=item.ID %>"><img width="60" height="40" src="<%=item.Path%>"/><img style="vertical-align: middle" onclick="DeleteImge(<%=item.ID %>);" alt="Xóa" src="/images/delete22.png" /></span>
                      <%}
                        %>
                    </td>
                </tr>
                <%} %>
        </tbody>
    </table>
    <%}
    %>

    <script type="text/javascript">
        function DeleteImge(id) {
            var ur = "/Ad/DeleteImg/" + id;
            if (confirm("Bạn có chắc chắn muốn xóa ảnh mô tả này?")) {
                $.ajax({
                    url: ur,
                    type: 'POST',
                    success: function(html) {
                        if (html.toString() == "true") {
                            $('img' + id).remove();
                        }
                    },
                    error: function(mes) {
                        alert("Lỗi: " + mes.responseText);
                        return false;
                    }
                });
            }
        }
    </script>

</asp:Content>
